<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/tag/localeTag.tld" prefix="t"%>
<!-- <script type="text/javascript" src="resources/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="resources/js/manageCategory.js"></script>
<script type="text/javascript" src="resources/js/selectCategory.js"></script>
<script type="text/javascript" src="resources/js/validateCategory.js"></script> -->
<div class="leftMenu">
	<c:if test="${not empty user && user.roleId !=1}">
		<form action="showUserInfo" method="GET">
			<button type="submit" name="button" class="btn btn-info btn-lg btn-block" value="myQuestions">
				<t:locale mName="leftmenu.myQuestions" />
				<span class="glyphicon glyphicon-list"></span>
			</button>
			<button type="submit" name="button" class="btn btn-info btn-lg btn-block" value="myAnswers">
				<t:locale mName="leftmenu.myAnswers" />
				<span class="glyphicon glyphicon-list"></span>
			</button>
			<button type="submit" name="button" class="btn btn-info btn-lg btn-block" value="myFavorites">
				<t:locale mName="leftmenu.favorites" />
				<span class="glyphicon glyphicon-star"></span>
			</button>
		</form>
	</c:if>
	<div id="categories">
		<h2>
			<t:locale mName="leftmenu.categories" />
		</h2>
		<form action="showCategoryQuestion" method="GET" id="showCategoryQuestion">
			<table class="table table-hover">
				<c:forEach var="cat" items="${categories}">
					<tr>
						<td id="${cat.id}"><span onclick="selectCategory('${cat.name}')" class="col-xs-11">
								<span class="glyphicon glyphicon-share-alt"></span>
								${cat.name}
							</span> <c:if test="${user.roleId==1}">
								<span onclick="confirmDeleteCategory('${cat.id}', '${cat.name}')" class="glyphicon glyphicon-remove"></span>
							</c:if></td>
					</tr>
				</c:forEach>
			</table>
			<input type="hidden" name="categoryName" id="categoryName">
		</form>
		<c:if test="${user.roleId==1}">
			<div class="col-xs-12">
				<form id="addCategory" class="form-horizontal" action="addCategory" method="POST">
					<div class="form-group">
						<label for="cName" class="control-label">
							<t:locale mName="leftmenu.newCategory" />
						</label>
						<input type="text" class="form-control" id="cName" name="cName" placeholder="<t:locale mName="leftmenu.categoryName"/>">
					</div>
					<div class="form-group">
						<input type="submit" class="btn btn-info btn-block" value="<t:locale mName="leftmenu.addCategory"/>" name="addCategory">
					</div>
				</form>
			</div>
		</c:if>
	</div>
	<div id="confirmDelete">
		<div class="row">
			<div class="col-xs-9">
				<h4>
					<t:locale mName="leftmenu.confirmCategory" />
				</h4>
			</div>
			<div class="col-xs-3 text-right">
				<span onclick="confirmDeleteCategoryClose()" class="glyphicon glyphicon-remove"></span>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-12">
				<h2>
					<strong id="catName"></strong>
				</h2>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-12">
				<button type="button" class="btn btn-danger" onclick="deleteCategory()">
					<span class="glyphicon glyphicon-remove"></span>
					<t:locale mName="leftmenu.removeCategory" />
				</button>
			</div>
		</div>
	</div>
	<c:if test="${not empty result}">
		<div id="addCategoryResult">
			<script type="text/javascript">
				$('#parent_popup').show();
			</script>
			<div class="row">
				<div class="col-xs-9">
					<h2>
						<t:locale mName="leftmenu.result" />
					</h2>
				</div>
				<div class="col-xs-3 text-right">
					<span onclick="addCategoryResultClose();" class="glyphicon glyphicon-remove"></span>
				</div>
				<div class="col-xs-12 text-left">
					<h3>
						<c:if test='${result eq "exist"}'>
							<t:locale mName="leftmenu.alreadyExist" />
						</c:if>
						<c:if test='${result eq "added"}'>
							<t:locale mName="leftmenu.added" />
						</c:if>
						<strong>${cName}</strong>
					</h3>
				</div>
			</div>
			<div>
				<button type="button" class="btn btn-info" onclick="addCategoryResultClose();">
					<t:locale mName="leftmenu.ok" />
				</button>
			</div>
		</div>
	</c:if>
</div>